<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="configuration.aspx.cs" Inherits="GleamTech.FileVista.ConfigurationPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
		<title>FileVista Configuration Wizard</title>
		<link href="filevistacontrol/styles/default.css" rel="stylesheet" />
		<script src="filevistacontrol/scripts/library/utility.js" type="text/javascript"></script>
		<script type="text/javascript">
            function RadioButtonDBAccessClick() {
                enableElement('TextBoxAccessFilePath', true, null, true); 
                enableElement('TextBoxSqlServer', false, null, true); 
                enableElement('TextBoxSqlDatabase', false, null, true); 
                enableElement('CheckBoxSqlTrusted', false, null, true); 
                enableElement('TextBoxSqlUser', false, null, true); 
                enableElement('TextBoxSqlPassword', false, null, true)
            }

            function RadioButtonDBSqlClick() {
                enableElement('TextBoxAccessFilePath', false, null, true); 
                enableElement('TextBoxSqlServer', true, null, true); 
                enableElement('TextBoxSqlDatabase', true, null, true); 
                var CheckBoxSqlTrusted = enableElement('CheckBoxSqlTrusted', true, null, true);
                enableElement('TextBoxSqlUser', !CheckBoxSqlTrusted.checked, null, true); 
                enableElement('TextBoxSqlPassword', !CheckBoxSqlTrusted.checked, null, true)
            }

            function chooseRadioButtonDbType() {
                var RadioButtonDBAccess = document.getElementById('RadioButtonDBAccess');
                var RadioButtonDBSql = document.getElementById('RadioButtonDBSql');

                if (RadioButtonDBAccess.checked)
                    RadioButtonDBAccessClick();
                else
                    RadioButtonDBSqlClick();
            }
            
            function clickCheckBoxSqlTrusted(cb) {
                enableElement('TextBoxSqlUser', !cb.checked);
                enableElement('TextBoxSqlPassword', !cb.checked)
            }
            
            function showClientMessage(confirmMessage) {
                var fieldClientMessage = document.getElementById("FieldClientMessage");
                
                if (confirmMessage)
                    return confirm(fieldClientMessage.value);
                else
                    alert(fieldClientMessage.value);
            }
		</script>
    </head>
    <body id="BodyTag" runat="server" style="margin: 100px;">
        <form id="formSetup" runat="server">
            <asp:HiddenField ID="FieldSetupStep" runat="server" />
            <asp:HiddenField ID="FieldConnectionString" runat="server" />
            <asp:HiddenField ID="FieldClientMessage" runat="server" />
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="true" ShowSummary="false" />
			<table border="0" cellpadding="0" cellspacing="10" class="panel generalText" style="width: 500px;" align="center">
				<tr>
					<td>
                        <asp:Label ID="LabelSetupTitle" runat="server" style=" font-size: 16pt"></asp:Label>
                    </td>
					<td align="center" valign="top"><img width="48" height="48" style="border: none" src="images/setup.png" alt=""/></td>
				</tr>
				<tr>
				    <td colspan="2"><hr /></td>
				</tr>
				<tr>
				    <td colspan="2">
<%switch (setupStep) {%>
<%case 0:%>
				        <div id="divSetupStep0" runat="server">
				            Configuration was already completed before so the wizard can not run again for security reasons.
				            If you need to rerun the wizard, then manually set <b>IsConfigurationComplete</b> key to <b>0</b> in <b>App_Data\FileVista.config</b>
                        </div>
<%break;%>
<%case 1:%>
				        <div id="divSetupStep1" runat="server">
                            This wizard will guide you through the steps required to configure this FileVista instance.<br /><br />
				            <span style="font-weight: bold;">Information on this FileVista instance:</span>
                            <table border="0" cellpadding="0" cellspacing="10" class="generalText">
                                <tr>
                                    <td style="width: 200px">Application Version:</td>
                                    <td><asp:Label ID="LabelAppVersion" runat="server"></asp:Label></td>
                                </tr>
                                <tr>
                                    <td>Application Path:</td>
                                    <td><asp:Label ID="LabelAppPath" runat="server"></asp:Label></td>
                                </tr>
                            </table>
				            <span style="font-weight: bold;">Information on the environment:</span>
                            <table border="0" cellpadding="0" cellspacing="10" class="generalText">
                                <tr>
                                    <td style="width: 200px">Machine Name:</td>
                                    <td><asp:Label ID="LabelMachineName" runat="server"></asp:Label></td>
                                </tr>
                                <tr>
                                    <td>Operating System Version:</td>
                                    <td><asp:Label ID="LabelOSVersion" runat="server"></asp:Label></td>
                                </tr>
                                <tr>
                                    <td>ASP.NET Version:</td>
                                    <td><asp:Label ID="LabelAspNetVersion" runat="server"></asp:Label></td>
                                </tr>
                                <tr>
                                    <td>Current Windows Identity:</td>
                                    <td><asp:Label ID="LabelIdentity" runat="server"></asp:Label></td>
                                </tr>
                            </table>
                            <span style="font-weight: bold;">Important:</span>
                            <table border="0" cellpadding="0" cellspacing="10" class="generalText">
                                <tr>
                                    <td colspan="2" style="width: 450px">
                                    Current Windows Identity, ie. the windows user which is used to run this web application, should have <i>Modify</i> permission on the <i>App_Data</i> folder and the permission should be inherited by its subfolders. 
                                    The wizard can not continue if this permission is denied. Please refresh the page after you do a permission change. 
                                    </td>
                                </tr>
                                <tr>
                                    <td>App_Data Physical Path:</td>
                                    <td><asp:Label ID="LabelAppDataPath" runat="server"></asp:Label></td>
                                </tr>
                                <tr>
                                    <td>Permission:</td>
                                    <td><asp:Label ID="LabelPermission" runat="server" style="font-weight:bold"></asp:Label></td>
                                </tr>
                            </table>
                        </div>
<%break;%>
<%case 2:%>
                        <div id="divSetupStep2" runat="server">
				            <table border="0" cellpadding="0" cellspacing="10" class="generalText">
				                <tr>
				                    <td>
                                        <asp:RadioButton ID="RadioButtonDBAccess" runat="server" Text="Access Database" GroupName="DatabaseType" />
                                        <table id="tableAccess" border="0" cellpadding="0" cellspacing="10" class="generalText" style="margin-left: 10px;">
                                            <tr>
                                                <td colspan="2">
                                                It is recommended that you keep the Access Database file (.mdb file) in the default location.
                                                Physical and virtual paths are allowed.
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="white-space: nowrap">File Path:</td>
                                                <td><asp:TextBox ID="TextBoxAccessFilePath" runat="server" style="width: 300px"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <b>Important:</b> Current Windows Identity should have <i>Modify</i> permission on the folder that contains the .mdb file.
                                                </td>
                                            </tr>
                                        </table>
				                    </td>
				                </tr>
				                <tr>
				                    <td>
				                        <asp:RadioButton ID="RadioButtonDBSql" runat="server" Text="SQL Server Database" GroupName="DatabaseType" />
                                        <table id="tableSqlServer" border="0" cellpadding="0" cellspacing="10" class="generalText" style="margin-left: 10px;">
                                            <tr>
                                                <td colspan="2">Enter the information required to connect to the SQL Server.</td>
                                            </tr>
                                            <tr>
                                                <td style="white-space: nowrap">Server:</td>
                                                <td><asp:TextBox ID="TextBoxSqlServer" runat="server" style="width: 200px"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td style="white-space: nowrap">Database:</td>
                                                <td><asp:TextBox ID="TextBoxSqlDatabase" runat="server" style="width: 200px"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <asp:CheckBox ID="CheckBoxSqlTrusted" runat="server" Text="Trusted connection" />
                                                    <table border="0" cellpadding="0" cellspacing="10" class="generalText" style="margin-left: 10px;">
                                                        <tr>
                                                            <td style="width: 100px; white-space: nowrap">User:</td>
                                                            <td><asp:TextBox ID="TextBoxSqlUser" runat="server" style="width: 200px"></asp:TextBox></td>
                                                        </tr>
                                                        <tr>
                                                            <td style="white-space: nowrap">Password:</td>
                                                            <td><asp:TextBox ID="TextBoxSqlPassword" runat="server" style="width: 200px"></asp:TextBox></td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <b>Important:</b> If <i>Trusted connection</i> is selected then Current Windows Identity will be used to connect to the SQL Server.
                                                    Else, you need to provide a valid SQL Server user and password. In either case, the user should have <i>Reader</i> and <i>Writer</i> permissions on the database.
                                                </td>
                                            </tr>
                                        </table>				                        
				                    </td>
				                </tr>
				            </table>
                        </div>
<%break;%>
<%case 3:%>
                        <div id="divSetupStep3" runat="server">
                            <table border="0" cellpadding="0" cellspacing="10" class="generalText">
                                <tr>
                                    <td colspan="2">Enter a name and password for the Administrator user who will have access to the administration page.</td>
                                </tr>
                                <tr>
                                    <td style="width: 200px">Administrator Username:</td>
                                    <td>
                                        <asp:TextBox ID="TextBoxAdministrator" runat="server" style="width: 200px"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBoxAdministrator">!</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Password:</td>
                                    <td>
                                        <asp:TextBox ID="TextBoxPassword" runat="server" style="width: 200px" TextMode="Password"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBoxPassword">!</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Confirm Password:</td>
                                    <td>
                                        <asp:TextBox ID="TextBoxPasswordConfirm" runat="server" style="width: 200px" TextMode="Password"></asp:TextBox>
                                        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBoxPasswordConfirm" ControlToValidate="TextBoxPassword">!</asp:CompareValidator></td>
                                </tr>
                                <tr>
                                    <td colspan="2"><hr /></td>
                                </tr>
                                <tr>
                                    <td colspan="2">Choose a default culture for the application. The user interface language, number and date/time formats are dependant on the selected culture.</td>
                                </tr>
                                <tr>
                                    <td>Default Culture:</td>
                                    <td><asp:DropDownList ID="DropDownListCultures" runat="server" style="width: 200px"></asp:DropDownList></td>
                                </tr>
                                <tr>
                                    <td colspan="2"><hr /></td>
                                </tr>
                                <tr>
                                    <td colspan="2">Define a root folder. You can later change/delete this root folder or add another one. The path can be a physical path like <i>c:\some\folder</i>, a virtual path like <i>/some/folder</i> or a web application relative path like <i>~/some/folder</i>.</td>
                                </tr>
                                <tr>
                                    <td>Root Folder Name:</td>
                                    <td>
                                        <asp:TextBox ID="TextBoxRFName" runat="server" style="width: 200px"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBoxRFName">!</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Root Folder Path:</td>
                                    <td>
                                        <asp:TextBox ID="TextBoxRFPath" runat="server" style="width: 200px"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="TextBoxRFPath">!</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <b>Important:</b> Current Windows Identity should have <i>Modify</i> permission on the folder.
                                    </td>
                                </tr>
                            </table>
                        </div>
<%break;%>
<%case 4:%>
                        <div id="divSetupStep4" runat="server">
                        FileVista is now ready to run. You can login with the administrator user that was defined during setup.
                        <br /><br />
                        </div>
<%break;%>
<%}%>

				    </td>
				</tr>
				<tr>
				    <td colspan="2"><hr /></td>
				</tr>
			
				<tr>
					<td colspan="2" align="right">
    					<asp:Button ID="ButtonNext" runat="server" style="width: 80px" text="Next >" OnClick="ButtonNext_Click" />
                        <asp:Button ID="ButtonFinish" runat="server"  text="Run FileVista" OnClientClick="window.location='./'; return false" />
					</td>
				</tr>
			</table>
        </form>
    </body>
</html>
